//
//  UIButton+Extension.swift
//  01-界面搭建
//
//  Created by Apple on 15/11/3.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit
extension UIButton {
    
    convenience init(imageName:String,backgroudName:String) {
        self.init()
        //设置按钮属性
        
        setImage(UIImage(named: imageName), forState:UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState:UIControlState.Highlighted)
        //设置背景图片
        setBackgroundImage(UIImage(named: backgroudName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named:  backgroudName + "_highlighted"), forState: UIControlState.Highlighted)
        sizeToFit()
        
    }
    
    /// 便利构造函数
    ///
    /// - parameter title:     title
    /// - parameter color:     color
    /// - parameter imageName: imageName
    ///
    /// - returns: UIButton
    convenience init(title:String,color:UIColor,imageName:String) {
        self.init()
    setTitle(title, forState: .Normal)
    setTitleColor(color, forState: .Normal)
   setBackgroundImage(UIImage(named: imageName), forState: .Normal)
           sizeToFit()
    }
    convenience init(title:String,color:UIColor,imgName:String) {
        self.init()
        setTitle(title, forState: .Normal)
        setTitleColor(color, forState: .Normal)
        setImage(UIImage(named: imgName), forState: .Normal)
        sizeToFit()
    }

}